package com.gdufs.secondhandwebsite.controller;

import com.gdufs.secondhandwebsite.entity.Goods;
import com.gdufs.secondhandwebsite.entity.GoodsType;
import com.gdufs.secondhandwebsite.service.GoodsTypeService;
import com.gdufs.secondhandwebsite.util.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@Api(tags = "二手交易网站闲置商品类别类相关接口")
@RestController
@RequestMapping("goodstypes")
public class GoodsTypeController extends BaseController{
    @Autowired
    GoodsTypeService goodsTypeService;

    @ApiOperation(value = "获取一级闲置商品类别接口")
    @GetMapping("groups")
    public JsonResult<List<String>> getGoodsTypeGroup(){
         List<String> result =goodsTypeService.getGoodsTypeGroups();
        JsonResult jsonResult = new JsonResult<List<String>>(OK);
        jsonResult.setData(result);
        return  jsonResult;
    }

    @ApiOperation(value = "根据闲置商品一级类别获取二级类别接口")
    @PostMapping("typenames")
    public JsonResult<List<GoodsType>> getById(String groupname) {
        List<GoodsType> result =goodsTypeService.getGoodsTypeNamesByGroupName(groupname);
        JsonResult jsonResult = new JsonResult<List<GoodsType>>(OK);
        jsonResult.setData(result);
        return  jsonResult;
    }

}
